﻿@model IEnumerable<LibMS.Models.LibDocuments>
@{
	ViewBag.Title = "Tìm kiếm";
	Layout = "~/Views/Shared/_Layout.cshtml";
}

<!-- Page info-->
<div class="well well-sm">
	<h4 class="text-success">
		@if (Convert.ToBoolean(ViewData["success"]) == true)
		{
			if (Model.Count() == 0)
			{
				<span>Không tìm thấy tài liệu nào.</span>
			}
			else
			{
				<span>Tìm được @ViewData["total"] tài liệu.</span>
			}
		}
	</h4>
</div>
<!-- /. End Page info-->
<div class="row">
	<!-- Document item-->
	<div class="col-lg-8">
		@if (Convert.ToBoolean(ViewData["success"]) == true)
		{
			<div id="documentItems">
				@foreach (var item in Model)
				{
					<div class="panel panel-default">
						<div class="panel-body">
							<div>
								<a href="@("/documents/detail/" + item.DocumentId)">
									<h3><strong>@item.DocumentName</strong></h3>
								</a>
							</div>

							<div class="well well-sm">
								<div class="row">
									<div class="col-lg-8 col-md-8">
										<b>Danh mục:</b>
										<a class="label label-default" href="LibDocuments/GetByCategory?categoryId=@item.CategoryId&categoryName=@item.CategoryName" rel="tag">@item.CategoryName</a>
									</div>
									<div class="col-lg-4 col-md-4">
										<b>Đăng ngày: </b>
										<abbr class="published" title="@String.Format("{0:dd/MM/yyyy HH:mm:ss}", item.CreateDate.GetValueOrDefault(Convert.ToDateTime("01/01/2013")))">@String.Format("{0:dd/MM/yyyy}", item.CreateDate.GetValueOrDefault(Convert.ToDateTime("01/01/2013")))</abbr>
									</div>
								</div>
							</div>

							<div class="row" style="padding-left:15px;">
								<div class="media">
									<a class="pull-left" href="@("/documents/detail/" + item.DocumentId)">
										<img class="img-thumbnail media-object" alt="100x130" style="width: 100px; height: 120px;" src="@(!string.IsNullOrEmpty(item.ThumbnaiPath) ? "../../Contents/Image/DocumentThumbnails/" + item.ThumbnaiPath : "../../Contents/Image/thumbnail-none.gif")">
									</a>
									<div class="media-body">
										<h4 class="media-heading">Mô tả tài liệu:</h4>
										@item.Descriptions
									</div>
								</div>
							</div>

							<div class="row xuong">
								<div class="col-md-10 col-sm-10">
									<p class="text-success"><strong>Lượt xem: <span class="badge">@item.ViewCount</span></strong></p>
								</div>
								<div class="col-md-2 col-sm-2">
									<a class="btn btn-success" href="@("/documents/detail/" + item.DocumentId)"><strong>Chi tiết ...</strong></a>
								</div>
							</div>
						</div>
					</div>
				}
			</div>
			<!-- Paging-->
			<div class="text-center">
				<ul id="paging" style="margin-top: 20px;"></ul>
			</div>
			<!-- /. End Paging-->
		}
		else
		{

		}
	</div>
	<!-- /.End Document item-->
    <!-- Right menu-->
    <div class="col-lg-4">
        <div id="rmCategories" class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title"><strong>Danh mục tài liệu</strong></h3>
            </div>
            <div class="list-group">
            </div>
        </div>

        <div id="rmDocumentsTopView" class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title"><strong>Tài liệu đọc nhiều</strong></h3>
            </div>
            <div class="list-group">
            </div>
        </div>
    </div>
    <!-- /. Right menu-->
</div>

@section JS {
	<script src="~/Scripts/App/LibDocuments/SearchDocument.js"></script>
	<script src="~/Scripts/Plugins/date.format.js"></script>
	<script type="text/javascript">
	    var total = @Html.Raw((ViewData["total"] ?? 0));
	    var searchDocuments = new SearchDocuments(total, 5, 1, '@Html.Raw(ViewData["searchKey"])');
		searchDocuments.Init();
	</script>
}